<template>
  <div class="aassess">

    <h3><span @click="fanh"><</span>安全考核列表</h3>
    <van-tabs @click="zhuan" class="ta">
      <van-tab title="全部"></van-tab>
      <van-tab title="未完成"></van-tab>
      <van-tab title="已完成"></van-tab>
    </van-tabs>

    <div class="neirong">
      <ul class="infinite-list" style="overflow:auto">
        <div id="center" v-for="sa in list">
          <span id="span1">{{ sa.assessTitle }}</span><br>
          <span id="span2">题目数量:{{sa.assessNum}}</span><br>
          <span id="span3" @click="chakan">查看培训内容></span>
          <span id="span4" v-if="sa.status==1">待完成></span>
          <span id="span5" v-if="sa.status!=1" @click="showPopup">已完成></span>
        </div>
      </ul>
    </div>
    <van-button class="butt" @click="fanh">返回</van-button>
    <van-popup
      v-model="show"
      closeable
      position="bottom"
      :style="{ height: '20%' }"
    />

  </div>
</template>
<script>
import axios from "axios";

export default {
  data() {
    return {
      list: {},
      show: false
    };
  },
  methods: {

    zhuan(index){
      if (index===0){
        axios.get('order/safetyAssess/findAll').then(res => {
          this.list = res.data
          console.log(this.list)
        })
      }else if (index===1){
        axios.get(`order/safetyAssess/findStatus?status=1`).then(res => {
          this.list = res.data
          console.log(this.list)
        })
      }else if (index===2){
        axios.get(`order/safetyAssess/findStatus?status=2`).then(res => {
          this.list = res.data
          console.log(this.list)
        })
      }else if (index===3){
        axios.get(`order/safetyAssess/findStatus?status=2`).then(res => {
          this.list = res.data
          console.log(this.list)
        })
      }
    },

    fanh(){
      this.$router.push('/securityCenter');
    },
    chakan(){
      this.$router.push('/assessContent');
    },

    getList() {
      axios.get('/order/safetyAssess/findAll')
        .then((response) => {
          this.list = response.data;
        })
        .catch((error) => {
          console.error("获取数据失败：", error);
        });
    },
    showPopup() {
      this.show = true;
    }
  },
  created() {
    this.getList();
  },
};
</script>
<style scoped>
h3{
  margin-left: 10px;
  span{
    margin-right: 140px;
  }
}
.aassess{
  width: 410px;
  height: 800px;
}
.neirong{
  width: 410px;
  height: 700px;
  background-color: #52b7fd;
  float: left;
  ul{
    width: 410px;
    height: 700px;
  }
}
#center{
  width: 400px;
  height: 100px;
  background-color: #FFFFFF;
  border-radius: 10px;
  float: left;
  margin-left: 5px;
  margin-top: 10px;
  line-height: 30px;
}
#span1{
  font-size: 19px;
  margin-left: 10px;
}
#span2{
  font-size: 15px;
  color: #7a7a7a;
  margin-left: 10px;

}
#span3{
  font-size: 15px;
  color: #00b1ff;
  margin-left: 10px;

}
#span4{
  float: right;
  margin-right: 10px;
  color: red;
}
#span5{
  float: right;
  margin-right: 10px;
}
.liebiao {
  margin-top: 10px;
  width: 400px;
  height: 30px;
  i {
    float: left;
    font-size: 20px;
    line-height: 40px;
    margin-left: 10px;
  }

  h4 {
    float: left;
    margin-left: 150px;
  }
}
.butt{
  width: 400px;
  height: 40px;
  color: white;
  background-color: #52b7fd;
  border-radius: 20px;
  margin-top: 20px;
}
</style>
